package com.atguigu.tingshu.album.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * title:
 * author: zgl
 * date: 2024/3/12
 * description：
 */
@Component
public class RedisLockClient {
    @Autowired
    private RedisTemplate redisTemplate;

    private String uuid;

    public RedisLockClient() {
        this.uuid = UUID.randomUUID().toString();
    }

    public RedisLock getLock(String lockName) {
        return new RedisLock(redisTemplate, lockName, uuid + ":" + Thread.currentThread().getId());
    }
}
